import React, { Component } from 'react'
import { Button, Text, TextInput, View } from 'react-native'
/**
 * input: null
 * output: 
 *      onUserAdd
 *          param: user
 */
export default class UserAddor extends Component {
    state={user:{}}
    _unameChange=uname=>{
        let user=this.state.user
        user.uname=uname
        this.setState({user})
    }
    _addressChange=address=>{
        let user=this.state.user
        user.address=address
        this.setState({user})
    }
    _confirm=()=>{
        this.props.onUserAdd(this.state.user)
    }
    render() {
        return (
            <View>
                <TextInput placeholder="请输入姓名" value={this.state.user.uname} onChangeText={this._unameChange}/>
                <TextInput placeholder="请输入地址"  value={this.state.user.address} onChangeText={this._addressChange}/>
                <Button title="确定" onPress={this._confirm}/>
            </View>
        )
    }
}
